home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJLSR106.ARJ / STDSTREA.CC < prev    next >
C/C++ Source or Header  |  1992-03-29  |  2KB  |  71 lines

  1. //    This is part of the iostream library, providing input/output for C++.
  2. //    Copyright (C) 1992 Per Bothner.
  3. //
  4. //    This library is free software; you can redistribute it and/or
  5. //    modify it under the terms of the GNU Library General Public
  6. //    License as published by the Free Software Foundation; either
  7. //    version 2 of the License, or (at your option) any later version.
  8. //
  9. //    This library is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. //    Library General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU Library General Public
  15. //    License along with this library; if not, write to the Free
  16. //    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #include "ioprivate.h"
  19. #include "ioconfig.h"
  20. #ifdef NAMES_HAVE_UNDERSCORE
  21. #define UNDERSCORE "_"
  22. #else
  23. #define UNDERSCORE ""
  24. #endif
  25.  
  26. struct _fake_filebuf;
  27.  
  28. extern _fake_filebuf _cin_sbuf, _cout_sbuf, _cerr_sbuf;
  29.  
  30. #if 0 /* defined(__GNUC__) */
  31. // This hack was intended to trick gdb into thinking cin is really a
  32. // istream (and not a _fake_istream), but doesn't seem to work.
  33. #define STR_NAME(TYPE, NAME) TYPE __##NAME asm(UNDERSCORE #NAME)
  34. #else
  35. #define STR_NAME(TYPE, NAME) TYPE NAME
  36. #endif
  37. #define cin CIN
  38. #define cout COUT
  39. #define cerr CERR
  40. #define clog CLOG
  41. #include "iostream.h"
  42. #undef cin
  43. #undef cout
  44. #undef cerr
  45. #undef clog
  46.  
  47. #ifdef __GNUG__
  48. #define PAD 0 /* g++ allows 0-length arrays. */
  49. #else
  50. #define PAD 1
  51. #endif
  52. class _fake_istream {
  53.     _ios_fields base;
  54.     char filler[sizeof(struct istream)-sizeof(struct _ios_fields)+PAD];
  55. };
  56. class _fake_ostream {
  57.     _ios_fields base;
  58.     char filler[sizeof(struct ostream)-sizeof(struct _ios_fields)+PAD];
  59. };
  60.  
  61. #define STD_STR(SBUF, TIE, EXTRA_FLAGS) \
  62.  (streambuf*)&SBUF, TIE, 0, ios::dont_close|ios::skipws|EXTRA_FLAGS, ' ', 0, 6
  63.  
  64. STR_NAME(_fake_ostream, cout)  = { STD_STR(_cout_sbuf, NULL, 0) };
  65. STR_NAME(_fake_ostream, cerr) =
  66.   { STD_STR(_cerr_sbuf, (ostream*)&cout, ios::unitbuf) };
  67. STR_NAME(_fake_istream, cin)  = { STD_STR(_cin_sbuf,  (ostream*)&cout, 0) };
  68.  
  69. /* Only for (partial) compatibility with AT&T's library. */
  70. STR_NAME(_fake_ostream, clog) = { STD_STR(_cerr_sbuf, (ostream*)&cout, 0) };
  71.